<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 5.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha256-xejo6yLi6vGtAjcMIsY8BHdKsLg7QynVlFMzdQgUuy8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"gz1234.gitee.io","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.12.3","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"flat"},"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="模块和加载器规范简介该文档主要的设计目标是定义前端代码的模块规范，便于开发资源的共享和复用。该文档在 amdjs 规范的基础上，进行了更细粒度的规范化。 编撰李玉北、erik、黄后锦、王杨、张立理、赵雷、陈新乐、顾轶灵、林志峰、刘恺华。 本文档由商业运营体系前端技术组审校发布。 要求在本文档中，使用的关键字会以中文+括号包含的关键字英文表示： 必须(MUST) 。关键字”MUST”, “MUST">
<meta property="og:type" content="website">
<meta property="og:title" content="郭泽">
<meta property="og:url" content="https://gz1234.gitee.io/spec-master/module.html">
<meta property="og:site_name" content="郭泽">
<meta property="og:description" content="模块和加载器规范简介该文档主要的设计目标是定义前端代码的模块规范，便于开发资源的共享和复用。该文档在 amdjs 规范的基础上，进行了更细粒度的规范化。 编撰李玉北、erik、黄后锦、王杨、张立理、赵雷、陈新乐、顾轶灵、林志峰、刘恺华。 本文档由商业运营体系前端技术组审校发布。 要求在本文档中，使用的关键字会以中文+括号包含的关键字英文表示： 必须(MUST) 。关键字”MUST”, “MUST">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-05-31T00:57:28.725Z">
<meta property="article:modified_time" content="2023-05-31T00:57:28.725Z">
<meta property="article:author" content="郭泽">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://gz1234.gitee.io/spec-master/module">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":false,"lang":"zh-CN","comments":true,"permalink":"https://gz1234.gitee.io/spec-master/module.html","path":"spec-master/module.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title> | 郭泽
</title>
  





  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">郭泽</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E5%92%8C%E5%8A%A0%E8%BD%BD%E5%99%A8%E8%A7%84%E8%8C%83"><span class="nav-number">1.</span> <span class="nav-text">模块和加载器规范</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AE%80%E4%BB%8B"><span class="nav-number">1.1.</span> <span class="nav-text">简介</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%96%E6%92%B0"><span class="nav-number">1.1.1.</span> <span class="nav-text">编撰</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A6%81%E6%B1%82"><span class="nav-number">1.1.2.</span> <span class="nav-text">要求</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E5%AE%9A%E4%B9%89"><span class="nav-number">1.2.</span> <span class="nav-text">模块定义</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#moduleId"><span class="nav-number">1.2.1.</span> <span class="nav-text">moduleId</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#factory"><span class="nav-number">1.2.2.</span> <span class="nav-text">factory</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#AMD%E9%A3%8E%E6%A0%BC%E4%B8%8ECommonJS%E9%A3%8E%E6%A0%BC"><span class="nav-number">1.2.2.1.</span> <span class="nav-text">AMD风格与CommonJS风格</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%8F%82%E6%95%B0"><span class="nav-number">1.2.2.2.</span> <span class="nav-text">参数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E7%B1%BB%E5%9E%8B"><span class="nav-number">1.2.2.3.</span> <span class="nav-text">类型</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#require"><span class="nav-number">1.2.2.4.</span> <span class="nav-text">require</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#exports"><span class="nav-number">1.2.2.5.</span> <span class="nav-text">exports</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dependencies"><span class="nav-number">1.2.3.</span> <span class="nav-text">dependencies</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E5%8A%A0%E8%BD%BD%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="nav-number">1.3.</span> <span class="nav-text">模块加载器配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#baseUrl"><span class="nav-number">1.3.1.</span> <span class="nav-text">baseUrl</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#paths"><span class="nav-number">1.3.2.</span> <span class="nav-text">paths</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E5%8A%A0%E8%BD%BD%E5%99%A8%E6%8F%92%E4%BB%B6"><span class="nav-number">1.4.</span> <span class="nav-text">模块加载器插件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8F%92%E4%BB%B6%E8%AF%AD%E6%B3%95"><span class="nav-number">1.4.1.</span> <span class="nav-text">插件语法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#css%E6%8F%92%E4%BB%B6"><span class="nav-number">1.4.2.</span> <span class="nav-text">css插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#js%E6%8F%92%E4%BB%B6"><span class="nav-number">1.4.3.</span> <span class="nav-text">js插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#tpl%E6%8F%92%E4%BB%B6"><span class="nav-number">1.4.4.</span> <span class="nav-text">tpl插件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#FAQ"><span class="nav-number">1.5.</span> <span class="nav-text">FAQ</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E8%83%BD%E9%87%87%E7%94%A8define-moduleId-deps-factory-%E6%9D%A5%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9D%97%EF%BC%9F"><span class="nav-number">1.5.1.</span> <span class="nav-text">为什么不能采用define(moduleId, deps, factory)来定义模块？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%9B%B8%E5%AF%B9%E4%BA%8E%E6%A8%A1%E5%9D%97%E7%9A%84Id%E5%92%8C%E7%9B%B8%E5%AF%B9%E4%BA%8E%E6%A8%A1%E5%9D%97Url%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F"><span class="nav-number">1.5.2.</span> <span class="nav-text">相对于模块的Id和相对于模块Url有什么区别？</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">郭泽</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">54</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">21</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">51</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner page posts-expand">


    
    
    
    <div class="post-block" lang="zh-CN"><header class="post-header">

<h1 class="post-title" itemprop="name headline">
</h1>

<div class="post-meta-container">
</div>

</header>

      
      
      <div class="post-body">
          <h1 id="模块和加载器规范"><a href="#模块和加载器规范" class="headerlink" title="模块和加载器规范"></a>模块和加载器规范</h1><h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>该文档主要的设计目标是定义前端代码的模块规范，便于开发资源的共享和复用。该文档<br>在 <a target="_blank" rel="noopener" href="https://github.com/amdjs/amdjs-api/wiki">amdjs</a> 规范的基础上，进行了更细粒度的规范化。</p>
<h3 id="编撰"><a href="#编撰" class="headerlink" title="编撰"></a>编撰</h3><p>李玉北、erik、黄后锦、王杨、张立理、赵雷、陈新乐、顾轶灵、林志峰、刘恺华。</p>
<p>本文档由<code>商业运营体系前端技术组</code>审校发布。</p>
<h3 id="要求"><a href="#要求" class="headerlink" title="要求"></a>要求</h3><p>在本文档中，使用的关键字会以中文+括号包含的关键字英文表示： 必须(MUST) 。关键字”MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”被定义在rfc2119中。</p>
<h2 id="模块定义"><a href="#模块定义" class="headerlink" title="模块定义"></a>模块定义</h2><p>模块定义 <em>必须(MUST)</em> 采用如下的方式：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">define( factory );</span><br></pre></td></tr></table></figure>

<p>推荐采用<code>define(factory)</code>的方式进行<code>模块定义</code>。使用匿名<code>moduleId</code>，从而保证开发中模块与路径相关联，有利于模块的管理与整体迁移。</p>
<p>SHOULD NOT使用如下的方式：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">define( moduleId, deps, factory );</span><br></pre></td></tr></table></figure>

<h3 id="moduleId"><a href="#moduleId" class="headerlink" title="moduleId"></a>moduleId</h3><p><code>moduleId</code>的格式应该符合 <a target="_blank" rel="noopener" href="https://github.com/amdjs/amdjs-api/wiki/AMD">amdjs</a> 中的约束条件。</p>
<ol>
<li><code>moduleId</code>的类型应该是<code>string</code>，并且是由<code>/</code>分割的一些<code>term</code>来组成。例如：<code>this/is/a/moduleId</code>。</li>
<li><code>term</code>应该符合<code>[a-zA-Z0-9_]+</code>这个规则。</li>
<li><code>moduleId</code>不应该有<code>.js</code>后缀。</li>
<li><code>moduleId</code>应该跟文件的路径保持一致。</li>
</ol>
<p><code>moduleId</code>在实际使用（如<code>require</code>）的时候，又可以分为如下几种类型：</p>
<ol>
<li><code>relative moduleId</code>：是以<code>./</code>或者<code>../</code>开头的<code>moduleId</code>。例如：<code>./foo</code>, <code>../../bar</code>。</li>
<li><code>top-level moduleId</code>：除上面两种之外的<code>moduleId</code>。例如<code>foo</code>，<code>bar/a</code>，<code>bar/b</code>。</li>
</ol>
<p>在模块定义的时候，<code>define</code>的第一个参数如果是<code>moduleId</code>， <em>必须(MUST)</em> 是<code>top-level moduleId</code>， <em>不允许(MUST NOT)</em> 是<code>relative moduleId</code>。</p>
<h3 id="factory"><a href="#factory" class="headerlink" title="factory"></a>factory</h3><h4 id="AMD风格与CommonJS风格"><a href="#AMD风格与CommonJS风格" class="headerlink" title="AMD风格与CommonJS风格"></a>AMD风格与CommonJS风格</h4><p>模块的<code>factory</code>有两种风格，<code>AMD推荐的风格</code>和<code>CommonJS的风格</code>。<code>AMD推荐的风格</code>通过返回一个对象做为模块对象，<code>CommonJS的风格</code>通过对<code>module.exports</code>或<code>exports的属性</code>赋值来达到暴露模块对象的目的。</p>
<p><em>建议(SHOULD)</em> 使用<code>AMD推荐的风格</code>，其更符合Web应用的习惯，对模块的数据类型也便于管理。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// AMD推荐的风格</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span> </span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        method: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">            <span class="keyword">var</span> foo = <span class="built_in">require</span>(<span class="string">&quot;./foo/bar&quot;</span>);</span><br><span class="line">            <span class="comment">// blabla...</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// CommonJS的风格</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="built_in">module</span>.exports = &#123;</span><br><span class="line">        method: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">            <span class="keyword">var</span> foo = <span class="built_in">require</span>(<span class="string">&quot;./foo/bar&quot;</span>);</span><br><span class="line">            <span class="comment">// blabla...</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h4 id="参数"><a href="#参数" class="headerlink" title="参数"></a>参数</h4><p>模块的<code>factory</code>默认有三个参数，分别是<code>require</code>, <code>exports</code>, <code>module</code>。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="comment">// blabla...</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>使用<code>AMD推荐风格</code>时，<code>exports</code>和<code>module</code>参数可以省略。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span> </span>) </span>&#123;</span><br><span class="line">    <span class="comment">// blabla...</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>开发者 <em>不允许(MUST NOT)</em> 修改<code>require</code>, <code>exports</code>, <code>module</code>参数的形参名称。下面就是错误的用法：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> req, exp, mod </span>) </span>&#123;</span><br><span class="line">    <span class="comment">// blablabla...</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h4 id="类型"><a href="#类型" class="headerlink" title="类型"></a>类型</h4><p><code>factory</code>可以是任何类型，一般来说常见的就是三种类型<code>function</code>, <code>string</code>, <code>object</code>。当<code>factory</code>不是<code>function</code>时，将直接做为模块对象。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/foo.js</span></span><br><span class="line">define( <span class="string">&quot;hello world. I&#x27;m &#123;name&#125;&quot;</span> );</span><br><span class="line"></span><br><span class="line"><span class="comment">// src/bar.js</span></span><br><span class="line">define( &#123;<span class="string">&quot;name&quot;</span>: <span class="string">&quot;fe&quot;</span>&#125; );</span><br></pre></td></tr></table></figure>

<p>上面这两种写法等价于：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/foo.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;hello world. I&#x27;m &#123;name&#125;&quot;</span>;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// src/bar.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"><span class="built_in">require</span></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> &#123;<span class="string">&quot;name&quot;</span>: <span class="string">&quot;fe&quot;</span>&#125;;</span><br><span class="line">&#125; );</span><br></pre></td></tr></table></figure>

<h4 id="require"><a href="#require" class="headerlink" title="require"></a>require</h4><p><code>require</code>这个函数的参数是<code>moduleId</code>，通过调用<code>require</code>我们就可以引入其他的模块。<code>require</code>有两种形式：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">require</span>( &#123;string&#125; moduleId );</span><br><span class="line"><span class="built_in">require</span>( &#123;<span class="built_in">Array</span>&#125; moduleIdList, &#123;<span class="built_in">Function</span>&#125; callback );</span><br></pre></td></tr></table></figure>

<p><code>require</code>存在<code>local require</code>和<code>global require</code>的区别。</p>
<p>在<code>factory</code>内部的<code>require</code>是<code>local require</code>，如果<code>require</code>参数中的<code>moduleId</code>的类型是<code>relative moduleId</code>，那么相对的是当前<code>模块id</code>。</p>
<p>在全局作用域下面调用的<code>require</code>是<code>global require</code>，<code>global require</code>不支持<code>relative moduleId</code>。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/foo.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span> </span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> bar = <span class="built_in">require</span>(<span class="string">&quot;./bar&quot;</span>); <span class="comment">// local require</span></span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// src/main.js</span></span><br><span class="line"><span class="comment">// global require</span></span><br><span class="line"><span class="built_in">require</span>( [<span class="string">&#x27;foo&#x27;</span>, <span class="string">&#x27;bar&#x27;</span>], <span class="function"><span class="keyword">function</span> (<span class="params"> foo, bar </span>) </span>&#123;     </span><br><span class="line">    <span class="comment">// blablalbla...</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h4 id="exports"><a href="#exports" class="headerlink" title="exports"></a>exports</h4><p><code>exports</code>是使用<code>CommonJS风格</code>定义模块时，用来公开当前模块对外提供的API的。另外也可以忽略<code>exports</code>参数，直接在<code>factory</code>里面返回自己想公开的API。例如下面三种写法功能是一样的：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="built_in">exports</span>.name = <span class="string">&quot;foo&quot;</span>;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> &#123; <span class="string">&quot;name&quot;</span> : <span class="string">&quot;foo&quot;</span> &#125;;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="built_in">module</span>.exports.name = <span class="string">&quot;foo&quot;</span>;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p><code>module</code>是当前模块的一些信息，一般不会用到。其中<code>module.exports === exports</code>。</p>
<h3 id="dependencies"><a href="#dependencies" class="headerlink" title="dependencies"></a>dependencies</h3><p>模块和模块的依赖关系需要通过<code>require</code>函数调用来保证。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/js/ui/Button.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="built_in">require</span>(<span class="string">&quot;css!../../css/ui/Button.css&quot;</span>);</span><br><span class="line">    <span class="built_in">require</span>(<span class="string">&quot;tpl!../../tpl/ui/Button.tpl.html&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">var</span> Control = <span class="built_in">require</span>(<span class="string">&quot;ui/Control&quot;</span>);</span><br><span class="line">    </span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@constructor</span></span></span><br><span class="line"><span class="comment">     * <span class="doctag">@extends <span class="type">&#123;Control&#125;</span></span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">Button</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">        Control.call(<span class="built_in">this</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">var</span> foo = <span class="built_in">require</span>(<span class="string">&quot;./foo&quot;</span>);</span><br><span class="line">        foo.bar();</span><br><span class="line">    &#125;</span><br><span class="line">    baidu.inherits(Button, Control);</span><br><span class="line"></span><br><span class="line">    ...</span><br><span class="line"></span><br><span class="line">    <span class="comment">// exports = Button;</span></span><br><span class="line">    <span class="comment">// return Button;</span></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>具体实现的时候是通过正则表达式分析<code>factory</code>的函数体来识别出来的。因此为了保证识别的正确率，请尽量<br>避免在函数体内定义<code>require</code>变量或者<code>require</code>属性。例如不要这么做：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> <span class="built_in">require</span> = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;&#125;;</span><br><span class="line"><span class="keyword">var</span> a = &#123;<span class="attr">require</span>:<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;&#125;&#125;;</span><br><span class="line">a.require(<span class="string">&quot;./foo&quot;</span>);</span><br><span class="line"><span class="built_in">require</span>(<span class="string">&quot;./bar&quot;</span>);</span><br></pre></td></tr></table></figure>

<p><a name="config"></a></p>
<h2 id="模块加载器配置"><a href="#模块加载器配置" class="headerlink" title="模块加载器配置"></a>模块加载器配置</h2><p><code>AMD Loader</code>应该支持如下的配置，更新配置的时候，写法如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">&quot;$&#123;amdloader.js&#125;&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript"><span class="built_in">require</span>.config(&#123;</span></span><br><span class="line">    ....</span><br><span class="line">&#125;);</span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="baseUrl"><a href="#baseUrl" class="headerlink" title="baseUrl"></a>baseUrl</h3><p>类型应该是<code>string</code>。在<code>ID-to-path</code>的阶段，会以<code>baseUrl</code>作为根目录来计算。如果没有配置的话，就默认以当前页面所在的目录为<code>baseUrl</code>。<br>如果<code>baseUrl</code>的值是<code>relative</code>，那么相对的是当前页面，而不是<code>AMD Loader</code>所在的位置。</p>
<h3 id="paths"><a href="#paths" class="headerlink" title="paths"></a>paths</h3><p>类型应该是<code>Object.&lt;string, string&gt;</code>。它维护的是<code>moduleId</code>前缀到路径的映射规则。这个对象中的<code>key</code>应该是<code>moduleId</code>的前缀，<code>value</code>如果是一个相对路径的话，那么相对的是<code>baseUrl</code>。当然也可以是绝对路径的话，例如：<code>/this/is/a/path</code>，<code>//www.google.com/this/is/a/path</code>。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    baseUrl: <span class="string">&#x27;/fe/code/path&#x27;</span>,</span><br><span class="line">    paths: &#123;</span><br><span class="line">        <span class="string">&#x27;ui&#x27;</span>: <span class="string">&#x27;esui/v1.0/ui&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;ui/Panel&#x27;</span>: <span class="string">&#x27;esui/v1.2/ui/Panel&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;tangram&#x27;</span>: <span class="string">&#x27;third_party/tangram/v1.0&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;themes&#x27;</span>: <span class="string">&#x27;//www.baidu.com/css/styles/blue&#x27;</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>在<code>ID-to-path</code>的阶段，如果<code>模块</code>或者<code>资源</code>是以<code>ui</code>, <code>ui/Panel</code>, <code>tangram</code>开头的话，那么就会去配置指定的地方去加载。例如：</p>
<ul>
<li><code>ui/Button</code> =&gt; <code>/fe/code/path/esui/v1.0/ui/Button.js</code></li>
<li><code>ui/Panel</code> =&gt; <code>/fe/code/path/esui/v1.2/ui/Panel.js</code></li>
<li><code>js!tangram</code> =&gt; <code>/fe/code/path/third_party/tangram/v1.0/tangram.js</code></li>
<li><code>css!themes/base</code> =&gt; <code>//www.baidu.com/css/styles/blue/base.css</code></li>
</ul>
<p>另外，需要支持为插件指定不同的的<code>paths</code>，语法如下：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    baseUrl: <span class="string">&#x27;/fe/code/path&#x27;</span>,</span><br><span class="line">    paths: &#123;</span><br><span class="line">        <span class="string">&#x27;css!&#x27;</span>: <span class="string">&#x27;//www.baidu.com/css/styles/blue&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;css!foo&#x27;</span>: <span class="string">&#x27;bar&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;js!&#x27;</span>: <span class="string">&#x27;//www.google.com/js/gcl&#x27;</span>,</span><br><span class="line">        <span class="string">&#x27;js!foo&#x27;</span>: <span class="string">&#x27;bar&#x27;</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="模块加载器插件"><a href="#模块加载器插件" class="headerlink" title="模块加载器插件"></a>模块加载器插件</h2><p>该文档不限定使用何种<code>AMD Loader</code>，但是一个<code>AMD Loader</code>应该支持至少三种插件（css，js，tpl）才能满足我们的业务需求。</p>
<h3 id="插件语法"><a href="#插件语法" class="headerlink" title="插件语法"></a>插件语法</h3><pre><code>[Plugin Module ID]![resource ID]</code></pre>
<p><code>Plugin Module Id</code>是插件的<code>moduleId</code>，例如<code>css</code>，<code>js</code>，<code>tpl</code>等等。<code>!</code>是分割符。</p>
<p><code>resource ID</code>是<code>资源Id</code>，可以是<code>top-level</code>或者<code>relative</code>。如果<code>resource ID</code>是<code>relative</code>，那么相对的是当前<code>模块的Id</code>，而不是当前<code>模块Url</code>。例如：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/Button.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>)</span>&#123;</span><br><span class="line">    <span class="built_in">require</span>( <span class="string">&quot;css!./css/Button.css&quot;</span> );</span><br><span class="line">    <span class="built_in">require</span>( <span class="string">&quot;css!base.css&quot;</span> );</span><br><span class="line">    <span class="built_in">require</span>( <span class="string">&quot;tpl!./tpl/Button.tpl.html&quot;</span> );</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>如果当前模块的路径是<code>$&#123;root&#125;/src/ui/Button.js</code>，那么该模块依赖的<code>Button.css</code>和<code>Button.tpl.html</code>的路径就应该分别是<code>$&#123;root&#125;/src/css/ui/Button.css</code>，<code>$&#123;root&#125;/src/tpl/Button.tpl.html</code>；该模块依赖的<code>base.css</code>的路径应该是<code>$&#123;baseUrl&#125;/base.css</code>。</p>
<h3 id="css插件"><a href="#css插件" class="headerlink" title="css插件"></a>css插件</h3><p>参考上面的示例。如果<code>resource ID</code>省略后缀名的话，默认是<code>.css</code>；如果有后缀名，以具体的后缀名为准。例如：<code>.less</code>。</p>
<h3 id="js插件"><a href="#js插件" class="headerlink" title="js插件"></a>js插件</h3><p>用来加载不符合该文档规范的js文件，例如<code>jquery</code>，<code>tangram</code>等等。例如：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// src/js/ui/Button.js</span></span><br><span class="line">define( <span class="function"><span class="keyword">function</span>(<span class="params"> <span class="built_in">require</span>, <span class="built_in">exports</span>, <span class="built_in">module</span> </span>) </span>&#123;</span><br><span class="line">    <span class="built_in">require</span>( <span class="string">&quot;js!jquery&quot;</span> );</span><br><span class="line">    <span class="built_in">require</span>( <span class="string">&quot;js!./tangram&quot;</span> );</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h3 id="tpl插件"><a href="#tpl插件" class="headerlink" title="tpl插件"></a>tpl插件</h3><p>如果项目需要前端模板，需要通过tpl插件加载。tpl插件由模板引擎提供方实现。插件的语法应该跟上述<code>js</code>，<code>css</code>插件的语法保持一致，例如：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">require</span>( <span class="string">&quot;tpl!./foo.tpl.html&quot;</span> );</span><br></pre></td></tr></table></figure>

<h2 id="FAQ"><a href="#FAQ" class="headerlink" title="FAQ"></a>FAQ</h2><h3 id="为什么不能采用define-moduleId-deps-factory-来定义模块？"><a href="#为什么不能采用define-moduleId-deps-factory-来定义模块？" class="headerlink" title="为什么不能采用define(moduleId, deps, factory)来定义模块？"></a>为什么不能采用define(moduleId, deps, factory)来定义模块？</h3><p><code>define(moduleId, deps, factory)</code>这种写法，很容易出现很长的deps，影响代码的风格。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">define(</span><br><span class="line">    <span class="string">&quot;module/id&quot;</span>, </span><br><span class="line">    [</span><br><span class="line">        <span class="string">&quot;module/a&quot;</span>, </span><br><span class="line">        <span class="string">&quot;module/b&quot;</span>, </span><br><span class="line">        <span class="string">&quot;module/c&quot;</span></span><br><span class="line">    ], </span><br><span class="line">    <span class="function"><span class="keyword">function</span> (<span class="params"> <span class="built_in">require</span> </span>) </span>&#123;</span><br><span class="line">        <span class="comment">// blabla...</span></span><br><span class="line">    &#125;</span><br><span class="line">);</span><br></pre></td></tr></table></figure>

<p>构建工具对代码进行处理和编译时，允许将代码编译成这种风格，明确硬依赖。</p>
<h3 id="相对于模块的Id和相对于模块Url有什么区别？"><a href="#相对于模块的Id和相对于模块Url有什么区别？" class="headerlink" title="相对于模块的Id和相对于模块Url有什么区别？"></a>相对于模块的Id和相对于模块Url有什么区别？</h3><p>还是看 <a target="_blank" rel="noopener" href="https://github.com/ecomfe/edp/issues/13#issuecomment-14383810">erik的解释吧</a></p>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
      </div>
      
      
      
    </div>

    
    


</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">郭泽</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/bookmark.js"></script>

  
<script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.0/search.js" integrity="sha256-vXZMYLEqsROAXkEw93GGIvaB2ab+QW6w3+1ahD9nXXA=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>

  <script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.8/pdfobject.min.js","integrity":"sha256-tu9j5pBilBQrWSDePOOajCUdz6hWsid/lBNzK4KgEPM="},"url":"/lib/pdf/web/viewer.html"}</script>
  <script src="/js/third-party/tags/pdf.js"></script>

  <script class="next-config" data-name="mermaid" type="application/json">{"enable":true,"theme":{"light":"default","dark":"dark"},"js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.1.3/mermaid.min.js","integrity":"sha256-TIYL00Rhw/8WaoUhYTLX9SKIEFdXxg+yMWSLVUbhiLg="}}</script>
  <script src="/js/third-party/tags/mermaid.js"></script>

  <script src="/js/third-party/fancybox.js"></script>


  





</body>
</html>
